﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace Weibo4Sharp.Model
{
    [Serializable]
    public class WeiboPrivacy : IWeiboModel, IEquatable<WeiboPrivacy>
    {
        public int Comment { get; set; }

        [JsonProperty("dm")]
        public int DirectMessage { get; set; }

        [JsonProperty("real_name")]
        public int RealName { get; set; }

        public int Geo { get; set; }

        public int Badge { get; set; }

        public string RawSource { get; set; }


        public override int GetHashCode()
        {
            var v = Comment & (DirectMessage << 1) & (RealName << 2) & (Geo << 3) & (Badge << 4);

            return v.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (!(obj is WeiboPrivacy)) return false;

            return Equals((WeiboPrivacy)obj);
        }

        public bool Equals(WeiboPrivacy other)
        {
            if (other == null) return false;

            return (Comment == other.Comment
                && DirectMessage == other.DirectMessage
                && RealName == other.RealName
                && Geo == other.Geo
                && Badge == other.Badge);
        }

        public static bool operator ==(WeiboPrivacy left, WeiboPrivacy right)
        {
            if (left == null || right == null) return false;
            return left.Equals(right);
        }

        public static bool operator !=(WeiboPrivacy left, WeiboPrivacy right)
        {
            return !(left == right);
        }
    }
}
